with open('passwd') as fr:
    aset = set(fr)

with open('mima') as fr:
    bset = set(fr)

with open('diff.txt', 'w') as fw:
    fw.writelines(bset-aset)